package com.reny.ll.git.core

import android.annotation.SuppressLint
import android.app.Activity
import android.app.ActivityManager
import android.content.Context
import kotlin.system.exitProcess


fun Any.act(): Activity{
    return LifecycleUtils.getTopAct()
}

fun Any.actTry(): Activity?{
    return try{act()}catch (e: Exception){null}
}

/*
 退出应用程序
 */
@SuppressLint("MissingPermission")
fun Any.exitApp(context: Context){
    val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
    activityManager.killBackgroundProcesses(context.packageName)
    exitProcess(0)
}